package com.clay.appointment.controller;

import com.clay.appointment.common.page.PageInfo;
import com.clay.appointment.common.response.Result;
import com.clay.appointment.entity.hospital.Hospital;
import com.clay.appointment.service.HospitalService;
import com.clay.appointment.vo.hospital.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : clay
 * @Description:
 * @Date: Create in 21:20 2021/8/9
 * @Modified By:
 */
@Api(tags="医院管理接口")
@RestController
@RequestMapping("/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;


    @ApiOperation(value = "获取分页列表")
    @GetMapping("list/{page}/{limit}")
    public Result<PageInfo<Hospital>> getHospitalPage(@ApiParam(value = "分页") @PathVariable Integer page,
                                                      @ApiParam(value = "每页数据条数") @PathVariable Integer limit,
                                                      @ApiParam(name = "hospitalQueryVo", value = "查询对象") HospitalQueryVo hospitalQueryVo) {
        PageInfo<Hospital> hospitalPageInfo = hospitalService.selectPage(page, limit, hospitalQueryVo);

        return Result.success(hospitalPageInfo);
    }


    @ApiOperation(value = "更新医院上线状态")
    @GetMapping("updateHospitalStatus/{id}/{status}")
    public Result updateHospitalStatus(
            @PathVariable("id") @ApiParam("医院id") String id,
            @PathVariable("status") @ApiParam("状态") boolean status) {
        hospitalService.updateStatus(id, status);
        return Result.success();
    }

    @ApiOperation("医院详情信息")
    @GetMapping("showHospitalDetail/{id}")
    public Result showHospitalDetail(@PathVariable("id") String id) {
        Hospital hospital = hospitalService.getHospitalById(id);
        return Result.success(hospital);
    }
}
